<?php

namespace addons\qingdong\model;

use think\Model;
use traits\model\SoftDelete;

/**
 *附件表
 */
class Feedback Extends Model {
	use SoftDelete;
    // 表名,不含前缀
    protected $name = 'qingdong_feedback';
	// 开启自动写入时间戳字段
	protected $autoWriteTimestamp = 'int';
	// 定义时间戳字段名
	protected $createTime = 'createtime';
	protected $updateTime = 'updatetime';
	protected $deleteTime = 'deletetime';

    /**
     * 反馈人
     * @return \think\model\relation\HasOne
     */
    public function staff(){
        return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name');
    }

    public function getFileIdsAttr($value){
        $files      = explode(',',$value);
        $files_v = [];
        foreach ($files as $fid) {
            if($fid){
                $curl = File::getUrl($fid);
                if($curl){
                    $files_v[] = cdnurl($curl, true);
                }
            }
        }
        return $files_v;
    }
    //获取创建时间
    public function getCreatetimeAttr($value) {
        return date('Y-m-d H:i:s', $value);
    }
}
